import axios from "axios";
import NProgress  from "nprogress";
import "nprogress/nprogress.css"

const request = axios.create({
    baseURL:"",
    timeout:"2000"
})

request.interceptors.request.use((config)=>{
    NProgress.start()
    return config
})

request.interceptors.response.use(
    (response)=>{
        NProgress.done()
        if(response.data.code === 200){
            return response.data.data
        }
        return Promise.reject({message:response.data.messa})
    },
    (error)=>{
        NProgress.done()
        return Promise.reject(error)
    }
)

export default request